package com.atguigu.yygh.sms.listener;

import com.atguigu.yygh.mq.MqConst;
import com.atguigu.yygh.sms.service.SmsService;
import com.atguigu.yygh.vo.msm.MsmVo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * ClassName: SMSListener
 * Package: com.atguigu.yygh.sms.listener
 * Description:
 *
 * @Author: cqk
 * @Create: 2023/10/6 - 13:14
 * @Version: v1.0
 */
@Component
public class SMSListener {
    @Autowired
    private SmsService smsService;

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue(name= MqConst.QUEUE_MSM_ITEM),
                    exchange = @Exchange(name = MqConst.EXCHANGE_DIRECT_MSM),
                    key = MqConst.ROUTING_MSM_ITEM
            )
    })
    public void consume(MsmVo msmVo, Message message, Channel channel){
        smsService.sendMsg(msmVo);
    }
}
